import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    meta: {
      title: "晶马商城-首页"
    }
  },
  {
    path: "/newProduct",
    name: "NewProduct",
    component: () => import("../views/NewProduct.vue"),
    meta: {
      title: "晶马商城-新品预售"
    }
  },
  {
    path: "/carCenter",
    name: "carCenter",
    component: () => import("../views/CarCenter.vue"),
    meta: {
      title: "晶马商城-整车中心"
    }
  },
  {
    path: "/FinanceSupport",
    name: "FinanceSupport",
    component: () => import("../views/FinanceSupport.vue"),
    meta: {
      title: "晶马商城-金融支持"
    }
  },
  {
    path: "/Customization",
    name: "Customization",
    component: () => import("../views/Customization.vue"),
    meta: {
      title: "晶马商城-深度定制"
    }
  },
  {
    path: "/ProductDetail",
    name: "ProductDetail",
    component: () => import("../views/ProductDetail.vue"),
    meta: {
      title: "晶马商城-商品详情"
    }
  },
  {
    path: "/buyCar",
    name: "BuyCar",
    component: () => import("../views/BuyCar.vue"),
    meta: {
      title: "晶马商城-在线购车"
    }
  },
  {
    path: "/payment",
    name: "Payment",
    component: () => import("../views/Payment.vue"),
    meta: {
      title: "晶马商城-选择支付方式"
    }
  },
  {
    path: "/topay",
    name: "topay",
    component: () => import("../views/ToPay.vue"),
    meta: {
      title: "晶马商城"
    }
  },
  {
    path: "/orderdetail",
    name: "orderdetail",
    component: () => import("../views/OderDetail.vue"),
    meta: {
      title: "晶马商城"
    }
  },
  {
    path: "/refundoderDetail",
    name: "refundoderDetail",
    component: () => import("../views/RefundOderDetail.vue"),
    meta: {
      title: "晶马商城"
    }
  },
  {
    path: "/menulist",
    name: "menulist",
    component: () => import("../views/MenuList.vue"),
    meta: {
      title: "晶马商城"
    }
  },
  {
    path: "/menudetail",
    name: "menudetail",
    component: () => import("../views/MenuDetail.vue"),
    meta: {
      title: "晶马商城"
    }
  },

  {
    path: "/success",
    name: "Success",
    component: () => import("../views/Success.vue"),
    meta: {
      title: "晶马商城-选择支付方式"
    }
  },
  {
    path: "/demo", //购车帮助
    name: "Demo",
    component: () => import("../views/Demo.vue"),
    meta: {
      title: "demo"
    }
  },
  {
    path: "/user",
    name: "User",
    redirect: "/user/info",
    component: () => import("../views/User/Index.vue"),
    children: [
      {
        path: "/user/info", //个人中心
        name: "Info",
        component: () => import("../views/User/tabs/Info.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/accountInfo", //账户信息
        name: "AccountInfo",
        component: () => import("../views/User/tabs/AccountInfo.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/address", //地址
        name: "BuyCarHelp",
        component: () => import("../views/User/tabs/Address.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/myOrder", //我的订购
        name: "MyOrder",
        component: () => import("../views/User/tabs/MyOrder.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/myRefund", //我的退订
        name: "MyRefund",
        component: () => import("../views/User/tabs/MyRefund.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/myCollect", //我的收藏
        name: "MyCollect",
        component: () => import("../views/User/tabs/MyCollect.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/feedback", //意见反馈
        name: "Feedback",
        component: () => import("../views/User/tabs/Feedback.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      {
        path: "/user/buyCarHelp", //购车帮助
        name: "BuyCarHelp",
        component: () => import("../views/User/tabs/BuyCarHelp.vue"),
        meta: {
          title: "晶马商城-个人中心"
        }
      },
      
    ]
  },
  {
    path: "/confirmOrder", //购车帮助
    name: "ConfirmOrder",
    component: () => import("../views/ConfirmOrder.vue"),
    meta: {
      title: "晶马商城-确认订单"
    }
  },
  {
    path: "/login", //登录
    name: "Login",
    component: () => import("../views/Login.vue"),
    meta: {
      title: "晶马商城"
    }
  },
  // {
  //   path: "/register", //注册
  //   name: "Register",
  //   component: () => import("../views/Register.vue"),
  //   meta: {
  //     title: "晶马商城"
  //   }
  // }
];

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}


export default router